DXF Geometry Import Converter
The DXF import converter is an intelligent and complex converter
which will take any DXF file of 2d, 2-1/2d or 3d entities and transform them
into optimized, grouped meshes of 3d polygons.
Whereas many DXF readers only read and convert 3D FACEs and 3d PolyMeshes, this
converter will read in all R12 entities and convert them to 3d polygon
equivalents. This includes processing all of the PolyLine attributes
(bulges, line widths and thickness), PolyMesh types (mesh, face and lines)
and 2d entities (lines, arcs and circles). In addition, the converter provides
5 powerful methods to "rip" apart the DXF file and convert it into
separate objects. Also, if the DXF file uses blocks and instances then they
will be converted into equivalent objects and instances within the
converter's database - this will create a very small imported database
since no data is duplicated unless necessary.
Highlights of the converter are as follows:
- Conformance to the AutoCAD R12 DXF specification.
- Reads both ASCII and binary versions of the DXF format.
- The 'scan mode' option allows the DXF file to be pre-scanned for color
numbers, layer names and block names.
- Retains blocks and instances within the imported database (no object
replication).
- Creates cameras from the VIEW entries found in the DXF file. The cameras
are compliant with the unpublished AutoCAD 'VIEW' algorithm for perspective
cameras.
- Reads in almost every popular DXF entity and converts them into optimized
3d polygon meshes by a variety of means.
- Allows 2d entities with no width or thickness to be intelligently converted
into 3d polygons of very narrow width. This allows, for example, 2d
drafting diagrams to be imported and rendered in 3-dimensions. It can also
be used, for example, to import GIS data that consists of DEM terrain and
simple 3d polylines (very powerful!). This feature
is quite useful since 3D AutoCAD diagrams often use 2d lines and 2d
arcs to add fine detail to a scene; without this feature such detail would
be non-existent within the 3d imported scene.
- All adjoining polylines which have been assigned "width" are properly mitred. The only other 3d DXF
converter that is known to have this capability is that provided with Autodesk's
3D Studio. Mitring adjusts the angle of abutting polygons so that they fit together
snuggly (as with the corners of a picture frame). The mitring code handles every
possible case, including 2d mitring (widened polylines) and 3d mitring (widened polylines
which are subsequently extruded upwards).
- The converter is extemely memory efficient, thanks to many
users sending rather large (> 10Mb) data files. You can only appreciate this efficiency
when you are presented with a 10-20Mb DXF file and you wish to have it processed into
a render-ready 3d model.
Supported Entities and their Conversion
In order for the converter to accept an entity into its internal database
the entity must be 3-dimensional. This excludes the direct importation
of DXF arcs, circles, lines and polylines since they have no area. However,
this DXF import converter performs a great deal of manipulation of these
2d entities so that they may be read in as 3d polygons. The conversion
process is described as follows:
-
arc - If an arc has 'width' then it will be turned into a series of polygons
that approximate an arc of the desired width (all arcs of 0-width can be
artificially widened so that they become 3d polygons by setting the
'line-arc-dummy-width' option non-zero). If the arc has thickness then
it will be extruded in the 'Z' direction of the ECS (entity's coordinate
system); in addition, if the 'add-end-faces' option is enabled then
the top and bottom faces of the extruded arc will be capped with polygons.
If the angle of the arc is 360 degrees then the arc will be replaced with
a circle.
-
circle - If a circle has no thickness then it will be converted into a flat 3d
'disc' which approximates a circle with a series of polygonal faces. If
the circle has 'thickness' then it will be extruded into a hollow cylinder
with no ends caps unless the 'add-end-faces' option is enabled.
-
line - If a line has 'width' then it will be widened into a 3d polygon
(of varying start and end widths). If the line has 'thickness' then it
will be extruded in the 'Z' direction into a single 3d polygon or a series
of 3d polygons defining a volume. If a line has no width or thickness then
it will be rejected by the converter unless the 'line-arc-dummy-width'
option is set non-zero in which cause the line will be artificially widened into
a very thin polygon; this latter option allows a 2d flat drafting diagram
(for example) to be turned into very thin polygons that can be subsequently
rendered in a 3d rendering program.
-
2d and 3d polylines. If the polyline has a non-zero 'bulge' factor in any of
its segments then those line segments will be replaced with segmented arcs. If
any line segments have a non-zero 'width' factor then those line segment(s)
will be replaced with 'fat line' segments represented as planar 3d polygons.
If any line segments have a non-zero 'thickness' factor then a 2d line segment
will be extruded upwards in the 'Z' direction to form a 3d polygon, whereas a
previously pre-widened 3d polygon (a line with a non-zero 'width' factor)
will be extruded upwards in the 'Z' direction to form an enclosed volume
defined by a number of polygons. If a polyline is not CLOSED, and it does
not have any width or thickness then the converter will not import it into
the 3d database (note, however, that if the 'line-arc-dummy-width'
option is set non-zero then such 2d lines will be widened into very thin
3d polygons).
-
polyface mesh. This is a series of vertices and their associated face indexes
that compactly specify a 3d object. This entity is very similar to the
'IndexedPolygon' primitive used internally within the converter's database
and as such this entity converts with little change.
-
polygon MxN mesh. This is a uniform grid of 3d polygons. The converter handles
the optional closure of the mesh in the M, N or M&N directions. The entity is
converted directly to the converter's internal 'IndexedPolygon' primitive.
-
3D face - 3d faces are collected and stored together as 3-point or 4-point
polygons in objects using the converter's internal 'IndexedPolygon' primitive.
-
trace - traces are 4 sided line segments with non-zero widths which
get converted to equivalent closed 3d polygons.
-
solid - solids get converted to 3 or 4 sided polygons. Do not confuse
the 2d simplistic 'solid' with AutoCAD R13's 3D Solid primitives.
-
insert - Blocks will be inserted with scale/rotate/translate transformations
and optionally the converter can instance a block several times in a
MxN grid. Note that instancing a block will not duplicate the block geometry data within the
converter's internal database - rather, instances will be created of the
imported block just as with AutoCAD.
Special Treatment of DXF Entities
The 2d polyline is given "extra special" treatment by the DXF converter.
First, all bulges in the polyline are converted to arc segments. Next, the
converter orients all of the resulting line segments of the polyline so
that they are connected in a head-to-tail fashion (a requirement of a 3d
polygon) and then the adjoining polyline segments are mitred together so
that no holes are evident.
Finally, the converter removes any redundant vertex coordinates
(such as the last one in the list) so that the vertices form a valid 3d
polygon. If the polyline has thickness (but no width) then the polyline
is extruded into a 3d volume and directly stored in the converter's internal
database as a highly efficient and verified mesh primitive. If the polyline
has width then it will be stored as a series of less-efficient individual
polygon faces. Since a polyline with extrusion is commonly used to
create 3d objects within an AutoCAD drawing, these processing steps
ensure that the resulting imported data will result in good 3d renderings
of such data.